#include "Fountain.h"

Slide* Fountain::fountain = NULL;

Fountain::Fountain(Point<float> pos) : MovingSprite() {
	loadBitmap();

	ani->go();
	ani->setSlide(fountain, .15);

	this->start(pos);

	waitTime = -1;
}

void Fountain::loadBitmap() {
	if(fountain != NULL)
		return;

	fountain = new Slide();

	fountain->image = al_load_bitmap("rsc/Objects/Fountain/Fountain.tga");
	fountain->slideHeight = 64;
	fountain->slideWidth = 64;
	fountain->numSlides = 9;
}

void Fountain::update() {
	if(ani->getCurrSlideNumber() == 7) {
		if(waitTime > 0) {
			if(al_get_time() - waitTime > 1) {
				waitTime = -1;
				ani->go();
			}
		}
		else {
			waitTime = al_get_time();
			ani->stop();
		}
	}
}

void Fountain::draw(Point<float> camPos) {
	al_draw_bitmap(ani->getImage(), pos.x - camPos.x, pos.y - camPos.y, 0);
}

void Fountain::deleteImages() {
	if(fountain == NULL)
		return;

	al_destroy_bitmap(fountain->image);
	delete fountain;
	fountain = NULL;
}